﻿<!DOCTYPE>
<html>

<head>
  <meta http-equiv="X-UA-Compatible" content="IE=EDGE;IE=11;IE=8,chrome=1" />
  <title></title>
  <link href="/InSiteWebApplication/Content/Easyui/themes/metro/easyui.css" rel="stylesheet" />
  <link href="/InSiteWebApplication/Content/Easyui/themes/icon.css" rel="stylesheet" />
  <style type="text/css">
    .logout {
      float: right;
      height: 100%;
      margin-right: 20px;
    }

    .logout a {
      color: #fff;
      text-decoration: none;
      margin: 0 5px;
    }

    .logout .m-btn-plain-active {
      color: #000;
    }

    .logout a:HOVER {
      text-decoration: underline;
    }

    /*导航横向菜单定制化*/
    #mainTab>.tabs-header {
      background: url(/InSiteWebApplication/images/MainMenuBackground.jpg) repeat;
      padding-top: 0px;
    }

    #dvCenter {
      border-width: 0 1px;
    }

    #mainTab .tabs .tabs-inner {
      background-color: transparent;
      color: #fff;
      border-width: 0px;
      font-weight: bold;
    }

    #mainTab .tabs .tabs-selected .tabs-inner {
      color: #777;
      background-color: #fff;
    }

    /*导航侧边菜单定制化*/
    #cc .layout-panel-west>.panel-header {
      background: url(/InSiteWebApplication/images/MainMenuBackground.jpg) repeat;
      border-width: 0px;
    }

    #cc .layout-panel-west>.panel-header .panel-title {
      color: #fff;
    }

    /*滚动条定制美化*/
    ::-webkit-scrollbar {
      width: 10px;
      /*对垂直流动条有效*/
      height: 10px;
      /*对水平流动条有效*/
    }

    /*定义滚动条的轨道颜色、内阴影及圆角*/
    ::-webkit-scrollbar-track {
      -webkit-box-shadow: inset 0 0 6px rgba(0, 0, 0, .3);
      border-radius: 3px;
    }


    /*定义滑块颜色、内阴影及圆角*/
    ::-webkit-scrollbar-thumb {
      border-radius: 7px;
      -webkit-box-shadow: inset 0 0 6px rgba(0, 0, 0, .3);
      background-color: #E8E8E8;
    }

    /*定义两端按钮的样式*/
    ::-webkit-scrollbar-button {
      display: none;
    }

    /*定义右下角汇合处的样式*/
    ::-webkit-scrollbar-corner {
      display: none;
    }

    .image,
    .text {
      display: inline-block;
      vertical-align: middle;
    }

    .link>a,
    .link>span {
      color: #fff;
      text-decoration: none;
      margin: 0 2px;
      height: 28px;
      line-height: 28px;
    }

    .dvCurrentInfo {
      display: inline-block;
      color: #fff;
      font-size: 14px;
      margin-left: 100px;
      height: 28px;
      line-height: 28px;
    }
  </style>
</head>

<body id="cc" class="easyui-layout">
  <button id="btnHidOrShowTop" class='icon-hamburg-up' title='隐藏头部区域' style="z-index: 10000;
        display: none; cursor: pointer; position: absolute; right: 0px; top: 30px; border: none;
        height: 20px">
  </button>

  <div id="dvNorth" data-options="region:'north',border:false" style="height: 53px;background-color: #0068B7;">
    <!-- logo -->
    <div style="display:inline-block;">
      <img src="../images/aeec_logo.png" alt="" class="image" style="height:53px;">
      <span class="text" style="font-size: 24px;font-weight: bold;color:#fff;font-family:黑体;">中国航发黎阳制造执行系统(内部)</span>
      <span class="text"
        style="font-size: 20px;font-weight: bold;color:red;font-family:黑体;margin-left: 20px;">内部系统，严禁处理涉密信息</span>
    </div>
    <!-- 版本信息 -->
    <span id="dvCurrentInfo" class="dvCurrentInfo"></span>

    <div class="link" style="position: absolute;top:10px;right: 10px;">
      <a href="#">主页</a>
      <span>|</span>
      <a id="aWorkReport" target="_blank">MES报工</a>
      <span>|</span>
      <a id="aReport" href="#" target="_blank">报表系统</a>
      <span>|</span>
      <!-- <a id="aPVS" href="#" target="_blank">
        PVS系统
      </a>
      <span>|</span> -->
      <!-- <a id="work_prepare" href="#" target="_blank">
        生产准备
      </a>
      <span>|</span> -->
      <a id="aProblemReaction" href="#" target="_blank">问题快反</a>
      <span>|</span>
      <a id="aProblemDeal" href="#" target="_blank">快反待办</a>
      <span>|</span>
      <a id="aStillWork" href="#" target="_blank">MES显示</a>
      <span>|</span>
      <a id="aHelp" href="#" target="_blank">帮助手册</a>
      <span>|</span>
      <a id="aLoginOut" href="#">退出</a>
    </div>
  </div>
  <div id="dvWest" data-options="onCollapse:function(){mainWorkPage.resizeIframePanelWidth()},onExpand:function(){mainWorkPage.resizeIframePanelWidth(2)},
    region:'west',split:false,title:'导航菜单'" style="width: 270px; height: 100%;">
    <div id="sm" style="width: 95%">
    </div>
  </div>
  <div id="dvCenter" data-options="region:'center'">
    <div id="mainTab"></div>
  </div>
</body>

</html>
<script src="/InSiteWebApplication/Content/Easyui/jquery.min.js" type="text/javascript"></script>
<script src="/InSiteWebApplication/Scripts/json2.js" type="text/javascript"></script>
<script src="/InSiteWebApplication/Content/Easyui/jquery.easyui.min.js" type="text/javascript"></script>
<script src="/InSiteWebApplication/Content/Easyui/easyui-lang-zh_CN.js" type="text/javascript"></script>
<script src="/InSiteWebApplication/Scripts/array.pollyfill.js" type="text/javascript"></script>
<script src="/InSiteWebApplication/Scripts/CustomPageJs/CustomCommon.js" type="text/javascript"></script>
<script src="/InSiteWebApplication/Scripts/crypto-js.min.js" type="text/javascript"></script>
<script src="/InSiteWebApplication/Scripts/secret.js" type="text/javascript"></script>
<script type="text/javascript">
    var mainWorkPage = {
        rootPath: getRootPath(), //网站根路径
        ajaxUrl: this.rootPath + "/Ashx/HomeHandler.ashx",
        userInfo: null,
        //初始化页面
        init: function () {
            mainWorkPage.bind();
            if (mainWorkPage.validateIsLoginSource() == false) {
                return;
            }
            mainWorkPage.loadUserInfo();
        },
        //页面事件绑定
        bind: function () {
            //选项卡绑定
            $('#mainTab').tabs({
                border: false,
                fit: true,
                onSelect: function (title, index) {
                    var tab = $('#mainTab').tabs('getTab', index);
                    var content = '<div style="width:100%;height:100%;z-index:-1;overflow:hidden;"><iframe class="ifr-openedPage" scrolling="auto" frameborder="0" src="' + tab.panel('options').url + '" style="width:100%;height:100%;padding:0;margin:0;display:block;" onLoad=""></iframe></div>';
                    if (tab.panel('options').url.indexOf("ZSVue") !== -1) { mainWorkPage.openVueUrl(tab.panel('options').url); }
                    if (tab.panel('options').url.indexOf("ProductWorkflowDataViewVue3Page") !== -1 && navigator.userAgent.indexOf('Trident') != -1) { mainWorkPage.openVueByChrome(tab.panel('options').url); }
                    else {
                        if (tab.panel('options').content == null || tab.panel('options').content != content || tab.panel('options').isUpdateSelect == true)//有此判断，第二次点击相同选项卡时不会再次刷新
                        {
                            $('#mainTab').tabs('update', {
                                tab: tab,
                                options: {
                                    content: content,
                                    isUpdateSelect: false//当选中时是否更新
                                }
                            });
                        }
                    }
                }
            });
            //退出绑定
            $("#aLoginOut").on("click", function () {
                mainWorkPage.loginOut();
            });
            //显示隐藏头部
            $("#btnHidOrShowTop").on("click", function () {
                mainWorkPage.hidOrShowTop(this);
            });
            //
            $("#mainTab .tabs").mouseenter(function () {
                $("#btnHidOrShowTop").show();
                setTimeout(function () {
                    $("#btnHidOrShowTop").hide();
                }, "5000");
            });
        },
        //隐藏或展示头部区域
        hidOrShowTop: function (btn) {
            if ($(btn).hasClass("icon-hamburg-down")) {
                //alert("添加");

                $(btn).removeClass("icon-hamburg-down");
                $(btn).addClass("icon-hamburg-up");
                $(btn).css("top", "30px");
                $(btn).attr("title", "隐藏头部区域");
                //return;
                $("#dvNorth").parent().css("display", "block");
                $("#dvWest").parent().css("top", "53px");
                $("#dvCenter").parent().css("top", "53px");
            } else {
                //alert("移除");
                $(btn).removeClass("icon-hamburg-up");
                $(btn).addClass("icon-hamburg-down");
                $(btn).css("top", "0px");
                $(btn).attr("title", "显示头部区域");
                //return;
                $("#dvNorth").parent().css("display", "none");
                $("#dvWest").parent().css("top", "0px");
                $("#dvCenter").parent().css("top", "0px");
            }
            $("#cc").layout('resize');
        },
        //重新调整iframe框架内页面的宽度,type:1折叠，2展开
        resizeIframePanelWidth: function (type) {
            var delay = 0; //延时描述
            if (type == 2) {
                delay = 1000;
            }

            setTimeout(function () {
                // var centerWidth = $("#mainTab").css("width");
                // var iframes = $("#mainTab .ifr-openedPage").contents();
                // console.log($("#mainTab .ifr-openedPage").contents().find(".panelSection").css("width"));
                var selected = $('#mainTab').tabs('getSelected');
                if (selected == null) {
                    return;
                }
                var tabs = $('#mainTab').tabs('tabs');
                tabs.forEach(function (item) {
                    var tabOptions = item.panel('options');
                    if (selected.panel('options').index == tabOptions.index) {
                        //$('#mainTab').tabs('update', { tab: item, options: tabOptions });
                    } else {
                        item.panel('options').isUpdateSelect = true;
                    }
                });
            }, delay); //5秒后自动关闭 

        },
        loginOut: function () {
            $.messager.confirm('退出', '确定退出系统?', function (r) {
                if (r) {
                    //清session,cookie
                    var param = {
                        action: "logOut"
                    };
                    $.ajax({
                        type: "Post",
                        url: getRootPath() + "/Ashx/HomeHandler.ashx",
                        data: param,
                        cashe: false,
                        async: true,
                        beforeSend: function () {
                            $.messager.progress({ text: '', msg: '退出中...' });
                        },
                        success: function (data) {
                            clearCookie('isLogin');
                            $.messager.progress('close');
                            window.location = getRootPath() + "/Login.aspx";
                        },
                        error: function (XMLHttpRequest, textStatus, errorThrown) {
                            $.messager.progress('close');
                            alert(XMLHttpRequest.responseText);
                        }
                    });
                }
            });
        }
        //增加首页
    , addHomePageTab: function (title, url) {
        //var content = '<div style="width:100%;height:100%;z-index:-1;overflow:hidden;"><iframe scrolling="auto" frameborder="0" src="' + url + '" style="width:100%;height:100%;padding:0;margin:0;display:block;" onLoad=""></iframe></div>';
        if ($('#mainTab').tabs('exists', title)) {

            $('#mainTab').tabs('select', title);
        } else {
            $('#mainTab').tabs('add', {
                title: title,
                closable: true,
                url: url
            });
        }
    }
        //增加选项卡页面
    , addTab: function (title, url, isUpdate) {
        url = getRootPath() + "/" + url;
        //var content = '<div style="width:100%;height:100%;z-index:-1;overflow:hidden;"><iframe scrolling="auto" frameborder="0" src="' + url + '" style="width:100%;height:100%;padding:0;margin:0;display:block;" onLoad=""></iframe></div>';
        if ($('#mainTab').tabs('exists', title)) {

            var selectTab = $('#mainTab').tabs('getTab', title);
            if (isUpdate) {
                $('#mainTab').tabs('update', {
                    tab: selectTab,
                    options: {
                        url: url
                    }
                });
            }
            $('#mainTab').tabs('select', title);
        } else {
            var ua = navigator.userAgent;
            if (ua.indexOf('Trident') != -1 && url.indexOf("ProductWorkflowDataViewVue3Page") !== -1) {
                mainWorkPage.openVueByChrome(url);
            } else {
                $('#mainTab').tabs('add', {
                    title: title,
                    closable: true,
                    url: url
                });
            }
        }

    }
    , //增加选项卡页面,用于加载默认菜单页面
        addTab2: function (title, url) {
            url = getRootPath() + "/" + url;
            $('#mainTab').tabs('add', {
                title: title,
                selected: false,
                url: url
            });
        }
    , //验证是否是login跳转而来
        validateIsLoginSource: function () {
            //检查是否是登陆而来
            if (getCookie("isLogin") == null) {
                var param = {
                    action: "logOut"
                };
                $.ajax({
                    type: "Post",
                    url: getRootPath() + "/Ashx/HomeHandler.ashx",
                    data: param,
                    cashe: false,
                    async: false,
                    beforeSend: function () {
                        $.messager.progress({ text: '', msg: '您未登陆,退出中...' });
                    },
                    success: function (data) {
                        $.messager.progress('close');
                        window.location = getRootPath() + "/Login.aspx";
                    },
                    error: function (XMLHttpRequest, textStatus, errorThrown) {
                        $.messager.progress('close');
                        alert(XMLHttpRequest.responseText);
                    }
                });
                return false;
            } else {
                return true;
            }

        }
    , //加载用户信息
        loadUserInfo: function () {
            var param = {
                action: "GetUserInfo",
                EmployeeName: getParam("EmployeeName")
            };
            $.ajax({
                type: "Post",
                url: getRootPath() + "/Ashx/HomeHandler.ashx?v=" + new Date().getTime(),
                data: param,
                cashe: false,
                async: true,
                beforeSend: function () {
                    $.messager.progress({ text: '', msg: '处理中...' });
                },
                success: function (data) {
                    $.messager.progress('close');
                    var result = JSON.parse(data);
                    var rootPath = getRootPath();
                    var ip = getIp();
                    if (result.userInfo != null) {
                        //用户登录信息
                        mainWorkPage.userInfo = result.userInfo
                        //各链接赋值
                        $("#aHelp").attr("href", rootPath + "/framework/Default.htm");
                        $("#aReport").attr("href", ip.replace("75","76") + "/MESReport/Login.aspx?giLoginUserName=" + result.userInfo.EmployeeName);
                        // $("#aPVS").attr("href", "http://10.15.7.194:8088/portal/ssologin_pvsmes.jsp?iv-user=" + result.userInfo.EmployeeName);
                        $("#aProblemReaction").attr("href", "http://10.15.7.194:8088/portal/ssologin_mes_feedback_new.jsp?iv-user=" + result.userInfo.EmployeeName);
                        $("#aProblemDeal").attr("href", rootPath + "/mes-feedback-task-list.html?employeeid=" + Encrypt(result.userInfo.EmployeeID));
                        $("#aStillWork").attr("href", rootPath + "/forms/custom/my/stillWork.html");
                        // $("#work_prepare").attr("href", "http://10.15.5.32:8088/portal/ssologin_scjhgl.jsp?iv_user=" + result.userInfo.EmployeeName);
                        // 新生产报工
                        var workReportURL = ip + "/InSiteWebApplication/forms/Custom/htmlPage/redirectToWorkReportPage.html?uid=" + Encrypt(result.userInfo.EmployeeID);
                        $("#aWorkReport").attr("href", workReportURL);
                        var menuData = result.menuInfo;
                        //左侧菜单栏
                        if (menuData.subMenu.length == 0) {
                            $("#cc").layout('remove', 'west');
                        } else {
                            //  for (var i = 0; i < menuData.subMenu.length; i++) {
                            //       menuData.subMenu[i].iconCls = 'icon-more';
                            //  }

                            $('#sm').sidemenu({
                                data: menuData.subMenu,
                                onSelect: function (item) { mainWorkPage.addTab(item.text, item.url); },
                                border: false
                            });
                        }

                        //默认页面加载
                        var homePageTitle = "";
                        if (!isNullOrWhiteSpaceStr(result.userInfo.HomePage)) {
                            var homeItem = menuData.subPage.find(function (item) {
                                if (("/InSiteWebApplication/" + item.url).indexOf(result.userInfo.HomePage) != -1) {
                                    return true;
                                }
                            });
                            if (homeItem == null) {
                                mainWorkPage.addHomePageTab("首页", result.userInfo.HomePage);
                            } else {
                                homePageTitle = homeItem.text;
                            }
                        }

                        //右侧固定页面
                        for (var i = 0; i < menuData.subPage.length; i++) {
                            mainWorkPage.addTab2(menuData.subPage[i].text, menuData.subPage[i].url);
                        }
                        //默认页面加载
                        if (!isNullOrWhiteSpaceStr(homePageTitle)) {
                            $('#mainTab').tabs('select', homePageTitle);
                        }

                        //用户信息
                        document.getElementById("dvCurrentInfo").innerHTML = result.strCurrentInfo;
                        //增加定时session检查                        
                        setTimeout(function () { mainWorkPage.judgeIsDelay(); }, 21 * 60 * 1000); //21分钟检查一次 

                        if (window.navigator.userAgent.indexOf('MSIE') === -1) {
                            var factorycodes = "600,601,604,607,608,609";
                            if (result.userInfo.Roles.indexOf('工人') != -1 && result.userInfo.Roles.indexOf('检验员') != -1) {
                                alert('当前用户同时存在检验员和工人角色');
                            } else {
                                if (result.userInfo.Roles.indexOf('工人') != -1 && factorycodes.indexOf(result.userInfo.FactoryCode) != -1) {
                                    window.open('/InSiteWebApplication/forms/Custom/htmlPage/ContainerStepWorkReportVue3Page.html?uid=' + Encrypt(result.userInfo.EmployeeID));
                                }
                                if (result.userInfo.Roles.indexOf('检验员') != -1 && factorycodes.indexOf(result.userInfo.FactoryCode) != -1) {
                                    window.open('/InSiteWebApplication/forms/Custom/htmlPage/ContainerCheckVue3Page.html?uid=' + Encrypt(result.userInfo.EmployeeID));
                                }
                                if (result.userInfo.Roles.indexOf('工人') != -1 && result.userInfo.FactoryCode === '603') {
                                    window.open('/InSiteWebApplication/forms/Custom/ZSVue/ContainerStepWorkReportPage.html?uid=' + Encrypt(result.userInfo.EmployeeID));
                                }
                                if (result.userInfo.Roles.indexOf('检验员') != -1 && result.userInfo.FactoryCode === '603') {
                                    window.open('/InSiteWebApplication/forms/Custom/ZSVue/ContainerCheckInfoManagePage.html?uid=' + Encrypt(result.userInfo.EmployeeID));
                                }
                            }
                        }

                    } else {
                        var alterW = $.messager.alert('错误', result.message, 'error', function () {
                            window.open(getRootPath() + '/Login.aspx', '_top');
                        });
                        alterW.window({ modal: true, onClose: function () { window.open(getRootPath() + '/Login.aspx', '_top'); } });

                    }
                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    $.messager.progress('close');
                    alert(XMLHttpRequest.responseText);
                }
            });
        }
    , //定时请求，看是否超期
        judgeIsDelay: function () {
            var isCycle = true
            $.ajax({
                type: "Post",
                url: getRootPath() + "/Ashx/HomeHandler.ashx?v=" + new Date().getTime(),
                cashe: false,
                async: true,
                data: { action: "JudgeDelay" },
                beforeSend: function () { },
                success: function (data) {
                    var result = JSON.parse(data);
                    if (result.Result) {
                        if (isCycle) {
                            setTimeout(function () { mainWorkPage.judgeIsDelay(); }, 21 * 60 * 1000); //每21分钟定时检查是否超期
                        }
                    } else //超期
                    {
                        var judgeDelay = $.messager.alert('错误', "登陆已超期，请重新登陆", 'error', function () {
                            window.open(getRootPath() + '/Login.aspx', '_top');
                        });
                        judgeDelay.window({ modal: true, onClose: function () { window.open(getRootPath() + '/Login.aspx', '_top'); } });
                        isCycle = false;
                        setTimeout(function () { judgeDelay.window('close'); }, 5000); //5秒后自动关闭                    
                    }
                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    alert(XMLHttpRequest.responseText);
                }

            });
        },
        openVueUrl: function (url) {//新增vue页面打开方式 add by lb 20240802
            var ua = navigator.userAgent;
            if (ua.indexOf('Trident') != -1) {
                $.messager.show({
                    msg: "基于Vue开发的页面，请选择高版本浏览器进行打开", showType: 'fade', style: {
                        right: '',
                        bottom: ''
                    }
                });
            } else {
                window.open(url + "?uid=" + Encrypt(mainWorkPage.userInfo.EmployeeID), "_blank");
            }
        },
        openVueByChrome: function (url) {
            var data = { APIUserName: mainWorkPage.userInfo.APIUserName,
                APIPassword: mainWorkPage.userInfo.APIPassword,
                EmployeeID: mainWorkPage.userInfo.EmployeeID,
                FactoryCode: mainWorkPage.userInfo.FactoryCode,
                FactoryID: mainWorkPage.userInfo.FactoryID
            }
            var objShell = new ActiveXObject("WScript.Shell");
            var cmd = 'cmd.exe /c start chrome " ' + url + '?uid=' + Encrypt(JSON.stringify(data));
            objShell.Run(cmd, 0, true);
        }
    }
  $(function () {
    mainWorkPage.init();
  });
</script>